package alscript.lua.bridge.util;

import com.imy.luasupport.util.LLog;

import org.luaj.vm2.LuaValue;

import java.lang.reflect.Method;

public class BridgeRunnable implements Runnable {
  private LuaValue mLuaValue;
  private Method mMethod;
  private Object[] mObjects;

  public BridgeRunnable(LuaValue luaValue, Method realMethod, Object[] objects) {
    this.mLuaValue = luaValue;
    this.mMethod = realMethod;
    this.mObjects = objects;
  }

  @Override
  public void run() {
    try {
      mLuaValue.call();
    } catch (Exception e) {
      if (e.getMessage()!=null && e.getMessage().equals("attempt to call nil")){
        LLog.e("App调用lua函数"+mMethod.getName()+" 发生错误,是否lua 未注册该方法？ 如非关键函数请忽略该提示");
      }
    }

  }
}
